import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {HttpClient} from '@angular/common/http';

@Component({
  selector: 'app-list',
  templateUrl: './list.component.html',
  styleUrls: ['./list.component.scss']
})
export class ListComponent implements OnInit {
  list: any;
  loading: any;

  constructor(
    private router: Router,
    private http: HttpClient,
  ) {
  }

  ngOnInit() {
    this.loading = true;
    this.http.get('/api/environment').subscribe(res => {
      this.list = res;
      this.loading = false;
    }, () => {
      this.loading = false;
    });
  }

  add() {
    this.router.navigate([`/environment/add`]);
  }

  edit(id: any) {
    this.router.navigate([`/environment/edit`, id]);
  }

  copy(id: any) {
    alert('还没实现');
  }

  delete(id: any) {
    alert('还没实现');
  }
}
